package com.vportal.portlet.vdoc.service.util;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class ReportUtil {
	
	public static void createCellNoBorder(HSSFRow row, short column, String value,
			HSSFWorkbook wb) {

		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_LEFT);		

		HSSFCell cell = row.getCell(column);
		if (cell == null)
			cell = row.createCell(column);
		//cell.setEncoding(wb.ENCODING_UTF_16);
		cell.setCellValue(value);
		cell.setCellStyle(style);
	}	
	
	public static void createCell(HSSFRow row, short column, String value,
			HSSFWorkbook wb) {

		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		style.setBorderBottom(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderLeft(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderRight(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderTop(HSSFCellStyle.SOLID_FOREGROUND);

		HSSFCell cell = row.getCell(column);
		if (cell == null)
			cell = row.createCell(column);
		//cell.setEncoding(wb.ENCODING_UTF_16);
		cell.setCellValue(value);
		cell.setCellStyle(style);
	}

	public static void createCellAlignLeft(HSSFRow row, short column, String value,
			HSSFWorkbook wb) {

		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
		style.setBorderBottom(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderLeft(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderRight(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderTop(HSSFCellStyle.SOLID_FOREGROUND);

		HSSFCell cell = row.getCell(column);
		if (cell == null)
			cell = row.createCell(column);
		//cell.setEncoding(wb.ENCODING_UTF_16);
		cell.setCellValue(value);
		cell.setCellStyle(style);
	}

	public static void createCellBold(HSSFRow row, short column, String value,
			HSSFWorkbook wb) {

		HSSFCellStyle style = wb.createCellStyle();
		HSSFFont font = wb.createFont();
		font.setColor((short) 0xc);
		font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
		style.setFont(font);
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		style.setBorderBottom(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderLeft(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderRight(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderTop(HSSFCellStyle.SOLID_FOREGROUND);

		HSSFCell cell = row.getCell(column);
		if (cell == null)
			cell = row.createCell(column);
		//cell.setEncoding(wb.ENCODING_UTF_16);
		cell.setCellValue(value);
		cell.setCellStyle(style);
	}

	public static void createCell(HSSFRow row, short column, int value,
			HSSFWorkbook wb) {
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		style.setBorderBottom(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderLeft(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderRight(HSSFCellStyle.SOLID_FOREGROUND);
		style.setBorderTop(HSSFCellStyle.SOLID_FOREGROUND);

		HSSFCell cell = row.getCell(column);
		if (cell == null)
			cell = row.createCell(column);
		cell.setCellValue(value);
		cell.setCellStyle(style);
	}
	
	
}
